package com.study.it.sms;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@EnableConfigurationProperties(SmsProperties.class)
@Configuration
public class SmsAutoConfig {
    //负责把SmsUtil配置到Spring容器中
    @Bean
    @ConditionalOnMissingBean(SmsUtil.class)
    public SmsUtil smsutil(SmsProperties properties){
        System.out.println("触发配置类，配置SmsUtil到Spring容器");
        SmsUtil util=new SmsUtil();
        util.setUrl(properties.getUrl());
        util.setUid(properties.getUid());
        util.setKey(properties.getKey());
        return util;
    }
}
